import React from 'react';
import styles from './style.css'
import {getHistory} from "../../util/uitls";
import pageRedux from '../pageRedux'
import MyLayout from '../../component/MyLayout';
import TalkItemList from "./talkItemList";
import TalkItem from "./tallItem";
import {GET_TALK_LIST} from "../../api/talk";
import {MyMap} from "../../util/lodash";
import Bottom from "../../component/bottom";

export class TalkList extends React.Component {
    constructor(props) {
        super()
        this.state = {}
    }

    async componentDidMount() {
        var user = this.props.getStore("app.user")
        var result1 = await  GET_TALK_LIST(user.id).catch(e => {
        })
        this.props.setStore("talk_list.lists", result1.result)
    }


    render() {
        var self = this
        var user = this.props.getStore("app.user")
        var lists = this.props.getStore("talk_list.lists")
        return <MyLayout title="正在聊天">
            <TalkItemList>
                {
                    MyMap(lists, item => {
                        return <TalkItem
                            me={user}
                            you={item}
                        ></TalkItem>
                    })
                }
            </TalkItemList>


            <Bottom/>
        </MyLayout>
    }
}

export default pageRedux(TalkList)